public class Application {
    public static void main(String[] args) {
    Simulator simulator = new Simulator();
    simulator.playSound(new Dog("wowowo", "Dog"));
    simulator.playSound(new Cat("miaomiaomiao", "Cat"));
    }
}
class Animal{
    String cry;
    String name;
    public void cry(String cry){
        System.out.println("叫声为:"+cry);
    }
    public void getAnimalName(String name){
        System.out.println("发出刚才叫声的动物的名字是:"+name);
    }
}
class Dog extends Animal{
    public Dog( String cry,String name){
        this.cry = cry;
        this.name = name;

    }
}
class Cat extends Animal{
    public Cat( String cry,String name){
        this.cry = cry;
        this.name = name;
    }
}
class Simulator{
    public void playSound(Animal animal){
        animal.cry(animal.cry);
        animal.getAnimalName(animal.name);
    }
}
